package com.zhou.sys.common.sso.security.extractor;


import com.zhou.sys.common.sso.exception.KissoException;

/**
 * <p>
 * JWT Header Token 提取器
 * </p>
 *
 */
public class JwtHeaderTokenExtractor implements SSOTokenExtractor {

    public static String HEADER_PREFIX = "Bearer ";

    @Override
    public String extract(String header) {
        if (null == header || "".equals(header)) {
            throw new KissoException("Authorization header cannot be blank!");
        }

        if (header.length() < HEADER_PREFIX.length()) {
            throw new KissoException("Invalid authorization header size.");
        }

        return header.substring(HEADER_PREFIX.length(), header.length());
    }
}
